/**
*  \file nvram.c
*
*  \brief
*
*  \author Michael J. Hohmann  <michael.hohmann@linde-mh.de>
*
*
*/

/*===============================================[ private includes  ]================================================*/
#include "nvram.h"
#include "../assertor/assertor.h"
#include "../systime/systime.h"
#include "../xmc4500/i2c_hw.h"
#include "../mcu/mcu.h"
/*===============================================[ private defines   ]================================================*/

/*===============================================[ private datatypes ]================================================*/

/** Private variables */
struct sd24xx256_obj nvram_sdev;

/*===============================================[ private variables ]================================================*/

/*===============================================[ private functions ]================================================*/
static void nvram_write_protection(BO value );

/*===============================================[ inline functions  ]================================================*/

/*===============================================[ public functions  ]================================================*/


RC nvram_initialize( void )
{
   return sd24xx256_construct( &nvram_sdev, (i2cgi_operating_func_t)i2c_master_read, (i2cgi_operating_func_t)i2c_master_write, nvram_write_protection, mcu_high_resolution_counter, 100 );
}

/*===============================================[ private functions ]================================================*/

static void nvram_write_protection(BO value )
{
	mcu_set_output(mcu_output_I2C_WP_CPU_M,value);
}


/***********************************************************************************************************************
*                             Copyright 2018 Linde Material Handling. All rights reserved.                             *
***********************************************************************************************************************/
